﻿using Basic.FlowCollect;
using Basic.FlowExtendService;
using Basic.FlowLocalEvent.Model;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;
using WeDonekRpc.Helper;

namespace Basic.FlowLocalEvent.SignFile
{
    [LocalEventName("Delete")]
    internal class ClearSignFileLog : IEventHandler<FlowAuditSignFileEvent>
    {
        private readonly IFlowAuditSignLogCollect _Service;
        private readonly IFileService _File;
        public ClearSignFileLog ( IFlowAuditSignLogCollect service, IFileService file )
        {
            this._File = file;
            this._Service = service;
        }

        public void HandleEvent ( FlowAuditSignFileEvent data, string eventName )
        {
            long[] fileId = this._Service.Clear(data.SignFile.Id);
            if ( !fileId.IsNull() )
            {
                this._File.Drop(fileId);
            }
        }
    }
}
